<?php
use DB;

/*
|--------------------------------------------------------------------------
| 复写官方函数
|--------------------------------------------------------------------------
|
| 官方函数库路径
| Illuminate/Support/helpers.php
|
*/

if (! function_exists('amountCount')) {
    function amountCount(){
        $count = array();
        $count['count'] = 0;
        $count['debt'] = 0;
        $count['amount'] = 0;
        $accountList = DB::table('account')->get();
        foreach ($accountList as $key => $account) {
            $count['count'] = $count['count'] + $account->amount;
            if($account->amount < 0){
                $count['debt'] = $count['debt'] + $account->amount;
            }else{
                $count['amount'] = $count['amount'] + $account->amount;
            }
        }
        return $count ;
    }
}

